<?php

namespace app\api\controller;

use app\common\logic\CartLogic;
use app\common\logic\MessageLogic;
use app\common\logic\UsersLogic;
use app\common\logic\OrderLogic;
use app\common\logic\CouponLogic;
use think\Page;
use think\Request;
use think\Verify;
use think\Db;

class Index extends ApiCommon
{
	
	/*
    * 初始化操作
    */
    public function _initialize()
    {
//      parent::_initialize();
//      if (session('?user')) {
//          $user = session('user');
//          $user = M('users')->where("user_id", $user['user_id'])->find();
//          session('user', $user);  //覆盖session 中的 user
//          $this->user = $user;
//          $this->user_id = $user['user_id'];
////          $this->assign('user', $user); //存储用户信息
//      }
    }
    
	//获得videoList
	public function Index(){
		
		$where = array(
            'pid'=>2,
            'enabled'=>1,
            'start_time'=>array('lt',strtotime(date('Y-m-d H:00:00'))),
            'end_time'=>array('gt',strtotime(date('Y-m-d H:00:00'))),
        );
		//广告
        $ad = D("ad")->where($where)->order("orderby desc")->cache(true,TPSHOP_CACHE_TIME)->select();
		
		
		$tjwhere = array(
            'pid'=>3,
            'enabled'=>1,
            'start_time'=>array('lt',strtotime(date('Y-m-d H:00:00'))),
            'end_time'=>array('gt',strtotime(date('Y-m-d H:00:00'))),
        );
		//为你优选
//      $tjad = D("ad")->where($tjwhere)->order("orderby desc")->cache(true,TPSHOP_CACHE_TIME)->select();
		
		$tjad = Db::view('ad','*')
	    ->view('goods','goods_id,goods_name,shop_price,market_price','goods.goods_id = ad.ad_link')
	    ->where($tjwhere)
	    ->select();
		
		$arr = getVideoList(0,1,0);
		$this->returnMsg('ok','',['vlist'=>$arr['arr'],'ad'=>$ad,'tjad'=>$tjad]);
	}
	
	public function smsTest(){
		$res = sendSms("8", '13641759653', ['name'=>'陪陪','order_id'=>'1113365254']);
		$this->returnMsg('ok',tpCache('sms')['sms_appkey'].'----'.tpCache('sms')['sms_platform'],$res);
	}
}
?>